<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>确认订单</title>
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta name="msapplication-tap-highlight" content="no">
		<link rel="stylesheet" href="css/common.css" />
		<link rel="stylesheet" href="css/confirm_order.css" />
		<link rel="stylesheet" href="css/swiper.min.css" />
		<link rel="stylesheet" href="layer_mobile/need/layer.css" />
		<script type="text/javascript" src="layer_mobile/layer.js"></script>
		<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="layer_mobile/layer.js"></script>
		<script type="text/javascript" src="js/font-size.js"></script>
		<script type="text/javascript" src="js/swiper.min.js"></script>
		<script type="text/javascript" src="js/jsonselect.js"></script>
		<script type="text/javascript" src="js/token.js"></script>
		<script type="text/javascript" src="js/token_success.js"></script>
		<script type="text/javascript" src="js/global_variable.js"></script>
		<script type="text/javascript" src="js/url_param.js"></script>
	</head>
	<style>
		.picker {
			z-index: 100000000;
		}
		
		.picker .picker-panel .wheel-wrapper .wheel {
			font-size: .3rem;
		}
		.addressDiv {
			width: 200%;
			position: relative;
		}
		
		.address {
			width: 50%;
			float: left;
		}
		
		.add_address {
			width: 100%;
			/*float: left;*/
		}
		
		.message {
			overflow: hidden;
		}
		
		.clear:after {
			display: block;
			clear: both;
			content: "";
			visibility: hidden;
			height: 0
		}
		
		.address ul.address_xiayiye {
			position: relative;
		}
	</style>
	<body style="background-color: #f9f9f9;">
		<header>
			<div class="title_top">
				<a href="goods_details.html" class="title_top_first">
					<img src="img/back1.png" class="hea_img" />
				</a>
				<span class="title_top_center">确认订单</span>
			</div>
		</header>
		<div class="main">
			<div class="message" style="display: none;">
				<p class="daishouhuo">收货人信息</p>
				<div class="addressDiv clear">
					<div class="address">
						<ul class="address_logo">
							<li class="address_logo_li">
								<img src="img/position.png" />
							</li>
						</ul>
						<ul class="address_loction">
							<li class="address_loction_li">
								<span class="address_loction_li_left">收货人：<span id="orderName"></span></span>
								<span class="address_loction_li_right" id="orderTel"></span>
							</li>
							<li class="address_loction_lisec"><span>收货地点：<span id="orderAddr"></span><span id="orderAddrx" style="display:inline;"></span></span>
							</li>
						</ul>
						<ul class="address_xiayiye" id="addressID">
							<li class="address_xiayiye_li">
								<a href="javascript: ;" class="address_a_guanli compile_layer" onclick="window.location='personal/adress_manage.html'">
									<img src="img/xiayiye.png" />
								</a>

							</li>
						</ul>
					</div>

				</div>
			</div>
			<div class="add_address add_layer" style="display:none">
				<img src="img/add.png">
				<span class='add_address_text'>添加收货地址</span>
			</div>
			<p class="xintiao">
			</p>
			<section class="sec_main">
				<p class="daishouhuo">支付方式</p>
				<ul class="sec_main_ul">
					<li>
						<a href="javascript:;" class="choose_a">
							<img src="img/weixinc.png" class="yinlian" /> 微信支付
							<img src="img/choiceicon.png" class="tacitly" />
						</a>
					</li>
				</ul>
			</section>
			<!--支付方式结束-->
			<div class="goods_list">
				<p class="goods_list_title">商品列表</p>
				<div class="shop_info">
					<div class="shop_info_img">
						<a href="javascript:;" class="shop_info_img_a">
							<!--<img src="http://www.jq22.com/img/cs/500x500a.png">-->
						</a>
					</div>
					<div class="shop_info_text">
					</div>
				</div>
			</div>
			<!-- 配送方式 -->
			<div class="distribution">
				<ul class="distribution_ul">
					<li class="distribution_ul_left">
						配送方式
					</li>
					<li class="distribution_ul_right">
						<span class="distribution_cost">快递</span><span class="distribution_price">￥<i>0.00</i></span>
					</li>
				</ul>
			</div>
			<div class="news_buyer">
				<ul class="main_infor_name">
					<li class="name_li">买家留言</li>
					<li class="name_li name_input">
						<textarea placeholder="请输入留言" class="detailDescribValue" id="textArea"></textarea>
					</li>
				</ul>
			</div>
			<div class="pop compile_pop" style="display: none;">
				<p class="pop_title"><span class="pop_add">添加收货地址</span><span class="pop_cancle">取消</span></p>
				<ul class="pop_ul">
					<li>
						<label>联系人</label>
						<input type="text" placeholder="请输入姓名" id="unusername" />
					</li>
					<li>
						<label>手机号</label>
						<input type="text" maxlength="11" placeholder="请输入手机号" id="uname" />
					</li>
					<li>
						<label>选择地区</label>
						<span class='choose_address'>请选择地区 <img src="img/xiayiye.png"></span>
					</li>
					<li>
						<label>详细地址</label>
						<textarea placeholder="请输入详细地址" id="addressJie"></textarea>
					</li>
				</ul>
				<div class="pop_save">保存</div>

			</div>
			<div class="goods_zhuangtaibtn">
				<span class="goods_zhuangtaibtn_span">
				</span>
				<button class="first_btn" type="button" id="btn">提交订单</button>
			</div>
		</div>
	</body>	
	<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
	<script>
	//alert(returnCitySN['cip'] + returnCitySN['cname']);
		window.jsel = JSONSelect;
		var urlObj = urlparam();
		// console.log(urlObj);
		var orderNum;
		var sku_name;//商品名称
		var sku_id;//商品id
		var typeId;//商品规格position==1时的id
		var modelId;//商品规格position==2时的id
		var first_attribute_id;
		var second_attribute_id;
		var orderType;//商品来源
		var ip; //获取用户终端ip
		var memberLevel;//会员
		var areaCode;//邮编
		// 			 var token=null;
		/*低价打折商品 grounpID=6*/
		var goods_price = $(".price").text()

		var token = localStorage.getItem('token');
        
		// function accDiv(arg1, arg2) {
		// 	var t1 = 0,
		// 		t2 = 0,
		// 		r1, r2;
		// 	try {
		// 		t1 = arg1.toString().split(".")[1].length;
		// 	} catch(e) {}
		// 	try {
		// 		t2 = arg2.toString().split(".")[1].length;
		// 	} catch(e) {}
		// 	with(Math) {
		// 		r1 = Number(arg1.toString().replace(".", ""));
		// 		r2 = Number(arg2.toString().replace(".", ""));
		// 		return(r1 / r2) * pow(10, t2 - t1);
		// 	}
		// }
		/*free模式*/
		
		//普通
		var uri = localStorage.getItem('uri_goods');
	
		$.ajax({
			url: domain_name_url + "/index",
			type: "GET",
			dataType: "jsonp", //指定服务器返回的数据类型
			data: {
				method: 'getSpu',
				spuId: uri,
				token: token,
				url_type: 'index'
			},
			success: function(data) {
			
				// 判断商品是不是秒杀价
				var goodTime = data.result.rs[4].planGroupInfo;// 获取倒计时里面的东西
				var goodSku = data.result.rs[5].sku;//获取sku里的东西
			
				var plan_group = goodTime[0].plan_group;//判断参加秒杀的商品
				var runing_status = goodSku[0].runing_status;//判断秒杀商品的价格
				//商品名称以及价格
				var spu_name = jsel.match('.spu_name', data.result.rs[1]);
				sku_name = jsel.match('.sku_name', data.result.rs[5].sku);
				//商品来源
				orderType = jsel.match('.source_code',data.result.rs[1]);
				var makep = data.result.rs[5].sku;
				// sku_id
				sku_id=jsel.match('.id',data.result.rs[5].sku);
				var makepr = localStorage.getItem('makepr');
				var buyconfine = jsel.match('.buyconfine', makep)[0];
				//秒杀价
				var marts = localStorage.getItem('mart');
				console.log(marts,'uri_goods')
				// 非会员
				var outside = jsel.match('.outsider_self', makep);
				
				// 会员
				var merside = jsel.match('.member_self', makep);
				 	memberLevel = JSON.parse(localStorage.getItem('memberLevel'));
				var parentUserHasMark = JSON.parse(localStorage.getItem('parentUserHasMark'));
				// 规格
				typeId = localStorage.getItem('typeId');
				modelId = localStorage.getItem('modelId');
				var id = jsel.match('.id', data.result.rs[0]);
				
				var aa = jsel.match('.position', data.result.rs);
				var bb = jsel.match('.attribute_value', data.result.rs);
				first_attribute_id = jsel.match('.first_attribute_id',data.result.rs[5].sku);
			
				second_attribute_id = jsel.match('.second_attribute_id',data.result.rs[5].sku);
				
				// 数量
				var number = localStorage.getItem('num');
				//选择商品的sku图片
				var imageurl = jsel.match('.image_path', data.result.rs[2]);
				var listhtml = '';
				// for(var i = 0; i < spu_name.length; i++) {
				// 	listhtml += '<img src=' + imageurl[0] + '>';

				// }
				listhtml += '<img src=' + imageurl[0] + '>';
				$(".shop_info_img_a").html(listhtml)
				//商品列表
				var goodsInfo = '<h4>' + spu_name[0] + '</h4>';
				//如果不是从会员页面过来的商品
				if(orderType=='DG'){
					goodsInfo += ' <div class="shop_brief">';
				var index = null,
					index2 = null;
				for(var i = 0; i < aa.length; i++) {
					for(var j = 0; j < id.length; j++) {
						if(aa[i] == "1" && id[j] == typeId) {
							index = j;
						} else if(aa[i] == "2" && id[j] == modelId) {
							index2 = j;
						}
					}
				}
				goodsInfo += '<span>' + bb[index] + '</span>';
				if(index2 != null) {
					goodsInfo += '<span>' + bb[index2] + '</span>';
				}
				
				goodsInfo += '</div>';
				}
				//如果是从会员页面过来的商品
				if(orderType=='LB'){
					goodsInfo += ' <div class="shop_brief">';
					goodsInfo += '<span>' + bb+ '</span>'
					goodsInfo += '</div>'
				}
				goodsInfo += '<div class="order_line">';
				goodsInfo += '<div class="shop_price">';
				goodsInfo += '<div class="shop_pices" style="color: #e40012;">';
				if(plan_group ==1 && runing_status == 2){
			
					goodsInfo += '￥<i class="price">' + (marts/100).toFixed(2) + '</i>';
				}
				if(plan_group==2 || runing_status == 1 || runing_status ==3 || runing_status ==""  ){
					goodsInfo += '￥<i class="price">' + (makepr/100).toFixed(2) + '</i>';
				}
						
					
				
				if(memberLevel[0] == 0 && outside[0] != 0) {
					goodsInfo += '<span>';
					goodsInfo += '<span style="color:#595757;font-size:.3rem;">返现</span>';
					goodsInfo += '<font class="price_style" style="color: #e40012;">￥<font style="font-size: 0.5rem;">' + outside/100 + '</font></font>';
					goodsInfo += '</span>'
				}
				if(memberLevel[0] != 0 && merside[0] != 0) {
					goodsInfo += '<span>';
					goodsInfo += '<span style="color:#595757;font-size:.3rem;">返现</span>';
					goodsInfo += '<font class="price_style" style="color: #e40012;">￥<font style="font-size: 0.5rem;">' + merside/100 + '</font></font>';
					goodsInfo += '</span>'
				}

				goodsInfo += '</div>';
				goodsInfo += '</div>';
				if(buyconfine==0 && orderType == 'DG'){
					goodsInfo += '<div class="cart_buy">';
					goodsInfo += '<div class="cart_buy_jianjia">';
					goodsInfo += '<div class="cart_buy_jian">-</div>';
					goodsInfo += '<form>';
					goodsInfo += '<input readonly="readonly" class="input cart_buy_input" value="1" >';
					goodsInfo += '</form>';
					goodsInfo += '<div class="cart_buy_jia">+</div>';
					goodsInfo += '</div></div></div>';
				}
				
				$(".shop_info_text").html(goodsInfo);
				$('.input').val(number);
				if(plan_group ==1 || runing_status == 2){
					var pricehtml = '<span class="goods_money_spanfu">' + (marts/100 * number).toFixed(2) + '</span>';
					pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">' + number + '</font> 件商品）：</span>';
					$('.goods_zhuangtaibtn_span').html(pricehtml);
				}
				if(plan_group==2 || runing_status == 1 || runing_status ==3 || runing_status =="" ){
					var pricehtml = '<span class="goods_money_spanfu">' + (makepr/100 * number).toFixed(2) + '</span>';
					pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">' + number + '</font> 件商品）：</span>';
					$('.goods_zhuangtaibtn_span').html(pricehtml);
				}
				
				// 点击数量增加
				var repertory = localStorage.getItem("inventory");
				$(document).on("click", ".cart_buy_jia", function() {
					var orderNum = Number($(".cart_buy_input").val());
					var addOrderNum = orderNum + 1;
					$(".cart_buy_jian").css({
						'color': '#b61c25'
					});
					if(orderNum >= repertory) {
						$(this).css({
							'color': '#cccbcb'
						});
						layer.open({
							content: '库存不足',
							skin: 'msg',
							time: 2 //2秒后自动关闭
						});
						return
					}
					$(".cart_buy_input").val(addOrderNum);
					if(addOrderNum >= 1) {
						$(this).css({
							// 'color': '#cccbcb'
						});
					}
					if(orderType=='DG'){
						if(plan_group ==1 || runing_status == 2){
							var pricehtml = '<span class="goods_money_spanfu">' + (marts/100 * addOrderNum).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">' + addOrderNum + '</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
						if(plan_group==2 || runing_status == 1 || runing_status ==3 || runing_status =="" ){
							var pricehtml = '<span class="goods_money_spanfu">' + (makepr/100 * addOrderNum).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">' + addOrderNum + '</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
					
				}
					if(orderType=='LB'){
						if(plan_group =1 || runing_status == 2){
							var pricehtml = '<span class="goods_money_spanfu">' + (marts/100 * 1).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">1</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}else{
							var pricehtml = '<span class="goods_money_spanfu">' + (makepr/100 * 1).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">1</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
				
					}
					
				});
				// 点击数量减少
				$(document).on("click", ".cart_buy_jian", function() {
					var orderNum = Number($(".cart_buy_input").val());
					if(orderNum > 1) {
						$(".cart_buy_input").val(orderNum - 1);
						$(".cart_buy_jia").css({
							'color': '#b61c25'
						})
					} else if(orderNum == 1) {
						$(this).css({
							'color': '#cccbcb'
						});
						return
					}
					if(orderType=='DG'){
						if(plan_group ==1 || runing_status == 2){
							var pricehtml = '<span class="goods_money_spanfu">' + (marts/100 * (orderNum - 1)).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">' + (orderNum - 1) + '</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
						if(plan_group==2 || runing_status == 1 || runing_status ==3 || runing_status ==""){
							var pricehtml = '<span class="goods_money_spanfu">' + (makepr/100 * (orderNum - 1)).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">' + (orderNum - 1) + '</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
					
					}
					if(orderType=='LB'){
						if(plan_group ==1 || runing_status == 2){
							var pricehtml = '<span class="goods_money_spanfu">' + (marts/100 * 1).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">1</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
						if(plan_group==2 || runing_status == 1 || runing_status ==3 || runing_status ==""){
							var pricehtml = '<span class="goods_money_spanfu">' + (makepr/100 * 1).toFixed(2) + '</span>';
							pricehtml += '<span class="goods_money_span">合计（共 <font class="goods_money_num">1</font> 件商品）：</span>';
							$('.goods_zhuangtaibtn_span').html(pricehtml);
						}
					
					}
					
				});
				

			}
		});
		
		// 获取用户地址
		function getAddress() {
			$.ajax({
				url: domain_name_url + '/index',
				type: "GET",
				dataType: "jsonp", //指定服务器返回的数据类型
				data: {
					method: 'getAddress',
					token: token,
					url_type: 'index'
				},
				success: function(data) {
					if(data.success==1){
						var res=data.result.rs;
						if(res.length==0){
							$('.add_address').css('display', 'block');
						}else{
							var morenNum = "1"; //用户地址中is_default字段为1是默认地址
							var address = data.result.rs;
							var moren = jsel.match('.is_default', address); //检索出所有is_default字段
							//var moren=["0", "0", "0", "0", "0", "0"];//手动修改默认地址 测试
							var morentrue = moren.indexOf(morenNum); //is_default值为"1"的位置
							//判断有没有默认地址
							if(morentrue == "-1") { //没有默认地址 显示第一个地址
								var morenObj = address[0];
								$(".message").show();
								$("#orderName").html(morenObj.consignee);
								$("#orderTel").html(morenObj.consignee_tel);
								$("#orderAddr").html(morenObj.delivery_address)
								$("#orderAddrx").html(morenObj.delivery_addressSec);
								$("#addressID").attr("addressID", morenObj.id);
							} else { //有默认地址
								var morenObj = address[morentrue];
								$(".message").show();
								$("#orderName").html(morenObj.consignee);
								$("#orderTel").html(morenObj.consignee_tel);
								$("#orderAddr").html(morenObj.delivery_address)
								$("#orderAddrx").html(morenObj.delivery_addressSec);
								$("#addressID").attr("addressID", morenObj.id);

							}
						}
						
						for(var i=0;i<res.length;i++){
							var addid=localStorage.getItem('addid');
							var addname=localStorage.getItem('addname');
							var addphone=localStorage.getItem('addphone');
							var addsite=localStorage.getItem('addsite');
							var addsites=localStorage.getItem('addsites');
							if(data.result.rs.length > 0){
								if(res[i].id==addid){
									$("#orderName").html(addname);
									$("#orderTel").html(addphone);
									$("#orderAddr").html(addsite)
									$("#orderAddrx").html(addsites);
								}
							}
						}
					}
					
				}

			});

		}
		getAddress();
		
		// 弹框->收货地址
		window.onload = function() {
			var newAddress = {
				'unusername': "",
				'uname': '',
				'address': '',
				'addressJie': ''
			};
			$(document).on("click", ".add_layer", function() {

				layer.open({
					type: 1,
					content: $('.pop').html(),
					anim: 'up',
					scrollbar: false,
					shadeClose: false,
					style: 'position:fixed; bottom:30%;left: 5%; right:5%;height: auto;border:none; border-radius: 5px;'
				});
			});
			$(document).on("click", ".choose_address", function() {
				addaddress(this);
			});
			function addaddress(dom) {
				var first = []; /* 省，直辖市 */
				var second = []; /* 市 */
				var third = []; /* 镇 */

				var selectedIndex = [0, 0, 0]; /* 默认选中的地区 */

				var checked = [0, 0, 0]; /* 已选选项 */

				function creatList(obj, list) {
					obj.forEach(function(item, index, arr) {
						var temp = new Object();
						temp.text = item.name;
						temp.value = index;
						list.push(temp);
					})
				}

				creatList(city, first);

				if(city[selectedIndex[0]].hasOwnProperty('sub')) {
					creatList(city[selectedIndex[0]].sub, second);
				} else {
					second = [{
						text: '',
						value: 0
					}];
				}

				if(city[selectedIndex[0]].sub[selectedIndex[1]].hasOwnProperty('sub')) {
					creatList(city[selectedIndex[0]].sub[selectedIndex[1]].sub, third);
				} else {
					third = [{
						text: '',
						value: 0
					}];
				}

				var picker = new Picker({
					data: [first, second, third],
					selectedIndex: selectedIndex,
					title: ''
				});

				picker.on('picker.select', function(selectedVal, selectedIndex) {
					var text1 = first[selectedIndex[0]].text;
					var text2 = second[selectedIndex[1]].text;
					var text3 = third[selectedIndex[2]] ? third[selectedIndex[2]].text : '';

					$(dom).html(text1 + ' ' + text2 + ' ' + text3);
					newAddress.address = (text1 + ' ' + text2 + ' ' + text3);
				});

				picker.on('picker.change', function(index, selectedIndex) {
					if(index === 0) {
						firstChange();
					} else if(index === 1) {
						secondChange();
					}

					function firstChange() {
						second = [];
						third = [];
						checked[0] = selectedIndex;
						var firstCity = city[selectedIndex];
						if(firstCity.hasOwnProperty('sub')) {
							creatList(firstCity.sub, second);

							var secondCity = city[selectedIndex].sub[0]
							if(secondCity.hasOwnProperty('sub')) {
								creatList(secondCity.sub, third);
							} else {
								third = [{
									text: '',
									value: 0
								}];
								checked[2] = 0;
							}
						} else {
							second = [{
								text: '',
								value: 0
							}];
							third = [{
								text: '',
								value: 0
							}];
							checked[1] = 0;
							checked[2] = 0;
						}

						picker.refillColumn(1, second);
						picker.refillColumn(2, third);
						picker.scrollColumn(1, 0)
						picker.scrollColumn(2, 0)
					}

					function secondChange() {
						third = [];
						checked[1] = selectedIndex;
						var first_index = checked[0];
						if(city[first_index].sub[selectedIndex].hasOwnProperty('sub')) {
							var secondCity = city[first_index].sub[selectedIndex];
							creatList(secondCity.sub, third);
							picker.refillColumn(2, third);
							picker.scrollColumn(2, 0)
						} else {
							third = [{
								text: '',
								value: 0
							}];
							checked[2] = 0;
							picker.refillColumn(2, third);
							picker.scrollColumn(2, 0)
						}
					}

				});

				picker.on('picker.valuechange', function(selectedVal, selectedIndex) {
				
				});
				picker.show();
			}
			$(document).on("click", ".pop_cancle", function() {
				layer.closeAll('page');

			});
			// 姓名验证
			$(document).on("blur", "#unusername", function() {
				var reg = /^[A-Za-z0-9\u4e00-\u9fa5]{1,8}$/;
				var unusername = $(this).val().replace(/\s+/g, "");
				newAddress.unusername = unusername;
			
				if(!reg.test(unusername)) {
					layer.open({
						content: '请输入正确姓名',
						style: 'background-color:#fff; color:#666; border:none;font-size:0.3rem;', //自定风格
						time: 2
					});
				} else {

				}
			});
			// 手机号验证
			$(document).on("blur", "#uname", function() {
				var reg = /^1(3|4|5|7|8)\d{9}$/;
				var uname = $(this).val().replace(/\s+/g, "");
				newAddress.uname = uname;
				if(!reg.test(uname)) {

					layer.open({
						content: '手机号格式不正确',
						style: 'background-color:#fff; color:#666; border:none;font-size:0.3rem;', //自定风格
						time: 1
					});
				} else {

				}
			});
			// 验证详细地址
			$(document).on("blur", "#addressJie", function() {
				var addressJie = $(this).val().replace(/\s+/g, "");
				newAddress.addressJie = addressJie;
			});

			// 点击保存

			$(document).on("click", ".pop_save", function() {
				
				if(newAddress.unusername == '') {
					layer.open({
						content: '请输入姓名',
						skin: 'msg',
						time: 2
					});
					return false;
				} 
				if(newAddress.uname == '') {
					layer.open({
						content: '请输入手机号',
						skin: 'msg',
						time: 2
					});
					return false;
				} 
				if(newAddress.address == "") {
					layer.open({
						content: '请输入地区',
						skin: 'msg',
						time: 2
					});
					return false;
				}
				if(newAddress.addressJie == "") {
					layer.open({
						content: '请输入详细街道地址',
						skin: 'msg',
						time: 2
					});
					return false;
				}
//							
				$.ajax({
					url: domain_name_url + '/my',
					type: "GET",
					dataType: "jsonp", //指定服务器返回的数据类型
					data: {
						method: 'addAddress',
						token: token,
						deliveryAddress: newAddress.address,
						deliveryAddressSec: newAddress.addressJie,
						consignee: newAddress.unusername,
						consigneeTel: newAddress.uname,
						addressName: '公司',
						districtCode: '',
						isDefault: 0,
						url_type: 'my'

					},
					success: function(data) {
					
						$('.add_address').hide();
						getAddress();//成功后调取函数
					}
				})

			})
			
			//留言校验
			$('.detailDescribValue').bind('input propertychange', function() {
			    var val = $(this).val();
			    if (val.length > 90) {
			        $(this).val(val.substring(0, 90));
			    }
			});
			// 提交订单
			$(document).on("click", "#btn", function() {
				$('#btn').css('cursor','pointer');
				// alert(1)
				$.ajax({
					url: domain_name_url + '/index',
					type: "GET",
					dataType: "jsonp", //指定服务器返回的数据类型
					data: {
						method: 'getAddress',
						token: token,
						url_type: 'index'
					},
					success: function(data) {
						if(data.success == "1" && data.result.rs.length == 0) {
							$('.add_address').css('display', 'block');
							layer.open({
							content: '添加收货地址',
							skin: 'msg',
							time: 2 //2秒后自动关闭
							});
						}else{
							var orderName = $('#orderName').html();
							var orderTel = $('#orderTel').html();
							var orderAddr = $('#orderAddr').html();
							var orderAddrx = $('#orderAddrx').html();
							var orderTrans = $('.shop_info_text h4').html();
							var orderNums = $('.goods_money_num').html();
							var orderremark = $('.name_input textarea').val();
							newAddress = {
								'unusername': orderName,
								'uname': orderTel,
								'address': orderAddr,
								'addressJie': orderAddrx,
								'producename':orderTrans,
								'producenum':orderNums,
								'remark':orderremark

							}
						// 商品id
						var skuid;
					    for(var i = 0; i < sku_id.length; i++) {

						 	if(first_attribute_id[i]==typeId &&second_attribute_id[i]==0){
								skuid=sku_id[i];
						
						 	}else if(first_attribute_id[i]==typeId &&second_attribute_id[i]==modelId){
									skuid=sku_id[i];
							
							}
						}
						
						$.ajax({
							url: domain_name_url + "/order",
							type: "GET",
							contentType: "application/json",
							dataType: "jsonp", //指定服务器返回的数据类型
							data: {
								method: 'createOrder',
								skuId: skuid,
								token: token,
								deliveryAddress:newAddress.address+newAddress.addressJie,//地址
								consignee: newAddress.unusername,//姓名
								consigneeTel: newAddress.uname,//手机号
								transactionBody:sku_name[0],//商品名称
								orderType:orderType[0],
								skuNumber:newAddress.producenum,//商品数量
								remark:newAddress.remark,//留言
								deviceInfo:'WEB',
								sceneInfo:'{"h5_info": {"type":"Wap","wap_url": "https://jiangshidi.top","wap_name": "掌大优选"}}',
								dataSource: 'H5',
  								paymentWaykey:'WetCatH5',
  								spbillCreateIp:returnCitySN['cip'],
								url_type: 'order'
							},
							success: function(data) {
								$('.first_btn').attr("disabled","disabled");
								if(orderType=='LB'){
									memberLevel=1;
								}
							
								var mwebUrl = data.result.rs[1].mwebUrl
								
								window.location.href = mwebUrl;
								
							}
					    })
						}
					}
				})
				
			})
			
		}
	</script>
</html>